-
Notifications
You must be signed in to change notification settings - Fork 17
Exclude comment sections from workspace symbols by default #866
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: task/refactor-config
Are you sure you want to change the base?
Exclude comment sections from workspace symbols by default #866
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me, mostly just want some test coverage since this is a bit tricky
if let Some(existing_entry) = index.get(&entry.key) { | ||
// Give priority to non-section entries. | ||
if matches!(existing_entry.data, IndexEntryData::Section { .. }) { | ||
index.insert(entry.key.clone(), entry); | ||
} | ||
// Else, ignore. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a test for this behavior would be nice
deprecated: None, | ||
container_name: None, | ||
}); | ||
if state.config.workspace_symbols.include_comment_sections { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would enjoy seeing a test for this (on and off) as well if possible
}, | ||
|
||
IndexEntryData::Variable { name } => { | ||
info.push(SymbolInformation { | ||
name: name.clone(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could also add a nice test in goto_definition
for
# my_section ----
my_section <- function() {}
to make sure that my_section
is chosen
I know I'm also asking for a similar test in indexer
itself, but it feels like having a duplicate test in both places is a good idea (so if we ever see the indexer
test and think "why is this here?", then we'd also have the goto-definition test to show the real reason for it)
Branched from #865.
Addresses posit-dev/positron#4886.
When a comment section like
# name ---
clashes with an actual symbol likename <- function() {}
, whichever symbols comes first (usually the section) is included in the workspace index, and the other is ignored. Ideally we'd track both but for now we only track one identifier per file.This causes sections to win over function definitions in cases like this:
If you then jump to definition on a reference to that function, Positron jumps to the section instead of the function.
To fix this, we now allow functions and variables to overwrite sections in the indexer.
In addition, we no longer emit sections as workspace symbols by default. This can be turned back on with a new setting
positron.r.workspaceSymbols.includeCommentSections
. This is consistent with the fix in Exclude section headers from workspace symbols in R packages quarto-dev/quarto#755 where we no longer export markdown headers as workspace symbols by default, to avoid flooding workspace symbol quickpicks (#
prefix in command palette) with section headers.QA Notes
You should be able to command+quick on the
my_section
reference and be taken to the function definition rather than the section. This should be the case no matter the value ofpositron.r.workspaceSymbols.includeCommentSections
.When
positron.r.workspaceSymbols.includeCommentSections
is set totrue
, you should see comment sections in the workspace symbol quickpick. Otherwise they shouldn't be included.